<?php
/*
Template Name: News Template
*/
?>


<?php get_header(); ?>

<?php the_post(); 

$cust_back_img_id = get_post_meta($post->ID, 'arc_custom_background_image', true);

$cust_back_img = wp_get_attachment_url($cust_back_img_id);

?>

<!-- start Content Home -->				
<div class="content">


<div class="titlepage">
	<p><span><?php the_title(); ?></span></p>
</div>
<div class="slideimg">
	<?php if(!empty($cust_back_img)){ ?>
	<img src="<?php echo $cust_back_img; ?>" width="882px" height="564px">
	<?php } ?>
	
	<div class="content_news">
	<div class="news">
	
	<!-- Start News List -->
		<div class="newslinks">
			<ul class="links">
			
			 <?php 
			 		$news_list = get_posts( array( 'numberposts' => 7, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'news', 'post_status' => 'publish' ) );
			 		$news_total = 1; 
			 		
			 		//print_r($news_list);
			 ?>
			 
			 <?php foreach ($news_list as $nl) :  setup_postdata($nl);?>
			
				<!-- News List: Item <?php echo $news_total; ?> -->
				<li class="<?php if($news_total == 1) echo 'newsld firstitem'; ?>" id="news<?php echo $news_total; ?>">
					<a href="javascript:;">
						<div class="tnews">
							<p><span class="title"><?php echo $nl->post_title; ?></span></p>
							<p><?php echo get_the_date('M d, Y'); ?> <?php _e("by"); ?> <?php the_author(); ?></p>
						</div>									
					</a>							
				</li>
				<!-- End Item <?php echo $news_total; ?> -->
				<?php $news_total++; ?>
				<?php endforeach; ?>

				<!-- End Item 7 -->							
			</ul>
			<img src="<?php echo get_template_directory_uri(); ?>/img/stnews.png" class="stnews" alt="">
		</div>
		<!-- End News List -->
		
		<!-- Start News Content -->
		<div class="newscontent">
		
			<?php $news_total=1; foreach ($news_list as $nl2) :  setup_postdata($nl2);?>
			
			<?php
				
				$cust_news_img_id = get_post_meta($nl2->ID, 'arc_news_image', true);
				
				$cust_news_img = wp_get_attachment_url($cust_news_img_id);
				
			?>
			
				<!-- Start News #<?php echo $news_total; ?> -->
				<div id="divnews<?php echo $news_total; ?>" class="titledate" <?php if($news_total > 1) echo 'style="display:none;"'; ?>>
					<h4><span class="titlenews"><?php echo $nl2->post_title; ?></span><span class="date"> <?php echo get_the_date('d.m.Y'); ?></span></h4>
					<?php if(!empty($cust_news_img)){ ?>
						<a class="imgnews"><img src="<?php echo $cust_news_img; ?>" width="395px" height="110px"></a>
					<?php } ?>
					<p><span class="txtnews"><?php the_content(); ?></span></p>
					
				</div>
				<!-- End News #<?php echo $news_total; ?> -->
				<?php $news_total++; ?>
				<?php endforeach; ?>

		</div>
		<!-- End News Content -->
		
	</div>
	
</div>
</div>


		<div class="hidecorner"></div>
		
		</div>	
	</div>	
</div>

<?php get_footer(); ?>